package com.company.堆栈队列;

import java.util.Scanner;
import java.util.Stack;

/**
 * @author zhangjian
 * @data 2023/4/2
 * @Version 1.0
 * @Descripion
 */
public class AB5点击消除 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String str = input.nextLine();
        String res = delete(str);
        System.out.println(res);
    }

    private static String delete(String str) {
        Stack<Character> chars = new Stack<>();
        char[] array = str.toCharArray();
        for (int i = 0; i < array.length; i++) {
            if (chars.isEmpty()) {
                chars.push(array[i]);
            } else {
                if (chars.peek() == array[i]) {
                    //  当栈顶元素等于array[i]，弹出当前元素，判断栈的下一个元素是否还等于array[i]
                    while (!chars.isEmpty()) {
                        if (chars.peek() != array[i]) {
                            break;
                        }
                        chars.pop();
                    }
                } else {
                    chars.push(array[i]);
                }
            }
        }
        StringBuilder res = new StringBuilder();
        while (!chars.isEmpty()) {
            res.append(chars.pop());
        }
        if (res.length() == 0) {
            return "0";
        }
        return res.reverse().toString();
    }
}
